home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
doc
/
homepage
/
tutorials
/
lesson5
/
musical.wrl
< prev
next >
Wrap
Text File
|
1996-08-21
|
1KB
|
52 lines
#VRML V2.0 utf8
#Example of the use and control of sound
#Sphere which will act as an on/off switch
DEF SPHERE Transform {
translation 0 0 0
children [
DEF CLICKER TouchSensor {}
Shape {
appearance Appearance {
material Material {diffuseColor 0 0 1}
}
geometry Sphere {radius 3}
}
]
}
#Script to control the music
DEF MUSIC_SCRIPT Script {
url "musical.class"
scriptType "javabc"
field SFNode sphere_trans USE SPHERE
eventOut SFTime musicOn
eventOut SFTime musicOff
eventIn SFBool clicked
}
#sound node
DEF MUSICALSOUND Sound {
#inner radius - intensity is max within this
minBack 20
minFront 20
#outer radius - sound drops off between inner
#radius and this, and can't be heard beyond this
maxBack 50
maxFront 50
intensity 1
source DEF MUSICALCLIP AudioClip {
url "musical.wav"
loop TRUE
stopTime 1
}
}
#route for mouse click
ROUTE CLICKER.isActive TO MUSIC_SCRIPT.clicked
#routes for music control
ROUTE MUSIC_SCRIPT.musicOn TO MUSICALCLIP.set_startTime
ROUTE MUSIC_SCRIPT.musicOff TO MUSICALCLIP.set_stopTime